/*
 * Copyright 2011-2012 Rivoli team
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

ruleset {
	description 'Rivoli rules'

	AbcComplexity
	AbstractClassWithPublicConstructor
	AssignmentInConditional
	BigDecimalInstantiation
	BracesForClass
	BracesForForLoop
	BracesForIfElse
	BracesForMethod
	BracesForTryCatchFinally
	ClassSize(maxLines: 500)
	ClosureAsLastMethodParameter
	ConfusingClassNamedException
	ConfusingTernary
	CyclomaticComplexity
	DeadCode
	DuplicateImport
	DuplicateNumberLiteral
	DuplicateStringLiteral(ignoreStrings: ' ,\n')
	ElseBlockBraces
	EqualsAndHashCode
	ExplicitCallToCompareToMethod
	ExplicitCallToEqualsMethod
	ForStatementBraces
	GetterMethodCouldBeProperty
	GStringAsMapKey
	IfStatementBraces
	ImplementationAsType
	ImportFromSamePackage
	InvertedIfElse
	MethodCount(maxMethods: 15, doNotApplyToFilesMatching: /.*Test\.groovy/)
	MethodSize(maxLines: 25, doNotApplyToFilesMatching: /.*Test\.groovy/)
	NestedBlockDepth
	ParameterReassignment
	PrintStackTrace
	Println
	SystemErrPrint
	SystemOutPrint
	TernaryCouldBeElvis
	ThrowException
	ThrowRuntimeException
	UnnecessaryConstructor
	UnnecessaryGString
	UnnecessaryGetter
	UnnecessaryGroovyImport
	UnnecessaryNullCheck
	UnnecessaryParenthesesForMethodCallWithClosure
	UnnecessaryPublicModifier
	UnnecessaryReturnKeyword
	UnnecessarySemicolon
	UnusedImport
	// UnusedMethodParameter [until it recognises implemented interface methods without @Override]
	UnusedPrivateField
	// UnusedPrivateMethod [until it recognises invocations on other instances of the same class]
	UnusedPrivateMethodParameter
	UnusedVariable
	UseCollectNested
	WhileStatementBraces

	RequiredRegex {
		name = 'LicenseHeaderRequired'
		description = 'Files should start with the license header.'
		regex = /^\/\*(?s).+Copyright (\d{4}-)?\d{4} Rivoli team(?s).+Apache License, Version 2\.0(?s).+?\*\//
		priority = 3
	}

	IllegalRegex {
		name = 'TrailingWhitespaceNotAllowed'
		description = 'Lines should not end with spaces or tabs.'
		regex = /[ \t]+\r?\n/
		priority = 3
	}

	IllegalRegex {
		name = 'EmptyLineAtEndOfFileNotAllowed'
		description = 'Files should not end with an empty line.'
		regex = /\n$/
		priority = 3
	}
}